/**
 *	实验三
 *	设计一个类FileRWTest,实现从input.txt文件中读入数据到字符数组cBuffer中，然后再写入到
 *	文件“output.txt”中。
 */
import java.io.*;
class T5E03 
{
	public static void main(String[] args) 
	{
		FileRWTest.copy("input.txt","output.txt");
	}
}
class FileRWTest
{
	public static void copy(String in, String out)
	{
		FileInputStream fin = null;
		FileOutputStream fout = null;

		try
		{
			fin = new FileInputStream(in);
			fout = new FileOutputStream(out);	
			
			byte[] buffer = new byte[20];
			while (true)
			{
				int length = fin.read(buffer);
				if(length < 0) 
					break;	
				fout.write(buffer,0,buffer.length);
			}

		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			try
			{
				fin.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			try
			{
				fout.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}				
		}

	}
}